import { h } from 'vue';
import { NDataTable } from 'naive-ui';

export const withRowKey = (component) => {
  return {
    name: 'WithRowKey',
    props: {
      rowKey: {
        type: [Function],
        default: () => {return 'id'},
      },
    },
    setup(props, { slots, attrs, emit }) {
      return () => {
        return h(component, { ...attrs, rowKey: () => {return 'id'} }, slots);
      };
    },
  };
};
export const PeaceDataTable = withRowKey(NDataTable);
